using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using OgilvyOne.Model;
using OgilvyOne.IDAL;
using System.Collections;


namespace OgilvyOne.SqlServerDAL
{
    public class conContent : IconContent
    {
        // Methods
        public void delete(int con_id, int ASSC_CONTENT_ID)
        {
            string cmdText = string.Concat(new object[] { "delete ASSC_CON where CON_ID=", con_id, " and ASSC_CONTENT_ID=", ASSC_CONTENT_ID });
            SqlParameter[] cmdParms = new SqlParameter[0];
            using (SqlConnection connection = new SqlConnection(SQLHelper.CONN_STRING_NON_DTC))
            {
                connection.Open();
                using (SqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        SQLHelper.ExecuteNonQuery(transaction, CommandType.Text, cmdText, cmdParms);
                        transaction.Commit();
                    }
                    catch (SqlException exception)
                    {
                        transaction.Rollback();
                        Console.WriteLine(exception.Message);
                    }
                }
            }
        }

        public void Insert(int con_id, int ASSC_CONTENT_ID)
        {
            string cmdText = string.Concat(new object[] { "INSERT INTO ASSC_CON(CON_ID,ASSC_CONTENT_ID) VALUES(", con_id, ",", ASSC_CONTENT_ID, ")" });
            SqlParameter[] cmdParms = new SqlParameter[0];
            using (SqlConnection connection = new SqlConnection(SQLHelper.CONN_STRING_NON_DTC))
            {
                connection.Open();
                using (SqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        SQLHelper.ExecuteNonQuery(transaction, CommandType.Text, cmdText, cmdParms);
                        transaction.Commit();
                    }
                    catch (SqlException exception)
                    {
                        transaction.Rollback();
                        Console.WriteLine(exception.Message);
                    }
                }
            }
        }
    }
}
